Jump to content

Psedo-VesselModule in VAB (How do I...)


Recommended Posts

Alright, first a bit of background for context.

I am redoing my AGX mod pretty much from the ground up to use the New UI and VesselModuels to significantly steamline how it works.

However I want to use the same GUI objects in the VAB as well as in flight which gives a problem because there is no "VesselModule" I can hook up to in the editor.

How I have done this previously is I made a data holding object that I passed to the GUI window's instantiate method and so it didn't matter what scene I was in, I was making the object I passed myself so I could keep it consistent across game scenes.

Now, I'm trying to get away from having to do that and just directly pass the object I am using, but in flight I'm going to be working inside a VesselModule which causes issues in the editor as there is no VesselModule present.

I can think of 3 options:

1) Instantiate a fake VesselModule in the editor somehow and use that.

2) Code my GUI instantiate to take multiple input types so it takes VesselModule in flight and something else in Editor (probably a custom data object).

3) Code my GUI instantiate to take a middle-man data object so it doesn't care what scene I'm in, my scene specific code takes care of the problem.

I have a pretty good idea how to do #3, think I know how to do #2 and wouldn't know where to start on #1.

However #3 is also the most complicated to implement, I'd really like to do #1 but don't have a clue how at the moment.

Note I don't need any of VesselModule's abilities or uses, I just need an object I can pass to my GUI.

Thoughts?

D.

Edited by Diazo
Link to comment
Share on other sites

Alright, looks like there's no nice clean answer here.

How I am going to proceed is with the data storage object. However, rather then being a "middle-man" object that resides between VesselModule and my GUI, I'm going instantiate a copy of it in every VesselModule and just have it as my data storage as a sub-class.

However, for this to work there is one other thing I need to check my assumptions about, if I pass one large data storage object around I'm not wasting memory over multiple smaller data objects right?

I have multiple GUI windows that each need some of the data in my DataObject. If I understand how referencing works, I'm not wasting memory by passing a GUI window my DataObject with a whole bunch of data it won't use correct? I'm not actually making a copy of the DataObject inside the GUI window, just passing it a reference to the DataObject instance inside the VesselModule.

D.

Link to comment
Share on other sites

  • 2 weeks later...
On 06/03/2017 at 8:14 PM, Diazo said:

Note I don't need any of VesselModule's abilities or uses, I just need an object I can pass to my GUI.

If you don't need the vessel module abilities in the VAB, you could consider using a KSP add-on which only runs when in the VAB. But I guess you have already considered that?

Link to comment
Share on other sites

That is part of the solution, yes.

What is boils down to is that in my current setup the data storage is baked into the KSPAddon modules so I didn't have a separate data object I could pass to the GUI, hence having to make a middle-man data object (and the associated overhead). In my current version the GUI is actually baked into the KSPAddons also, there's a reason I'm rewriting this mod from scratch.

So I was trying to find a way around that. My grand realization was the fact that I could make a Data storage class and use an instance of that inside my KSPAddon modules so I can just pass my data to the GUI without having to worry about any sort of middleman data object.

I still have to write separate KSPAddon's for flight and VAB, but that has to happen anyway because the scenes are so different.

D.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...