Jump to content

[Plugin, WIP, 1.2] Ship List


Kiwa

Recommended Posts

Hi,

a typical question I encounter about every time I play the game is: which of my stations or ships in orbit has some room to dump excess fuel. When one doesn't have many stations in orbit, this may be a simple matter of switching through each of them and checking, but I have grown tired of all the switching back and forth between the vessels and the Space Station/Tracking Station/Map. Loading times on the notebook aren't so funny, nevermind the lag on some of the larger objects. All I really wanted was a simple list of the relevant ships and their fuel status. So I pondered the idea of just writing an external script which quickly parses the persistent.sfs file to collect the information, but then decided to try to write an in-game plugin. After all, this is as good an excuse as any to install Unity and learn yet another language (C#).

So, the simple goal is: have a window with the list of ships, showing their fuel status, ideally both in the Space Center and also which in flight. It should not require saving any extra data - no files, no blocks in the (already seriously large) save games. Optional goal: allow direct switching to the ships from the Space Center (like one can switch to the relevant vessel in Kerbal Alarm Clock).

Current status:

 

  • basic GUI window established (You will note at once I'm not a GUI person. The last time I did any GUI work was ... (probably) a control panel for OS/2. Yes, that long ago. I do write code for a living, if they let me out of meetings, but either the devices have no UI at all, or it is all happily ncurses based.)
  • infrastructure to acquire, keep and display the ship data is in place
  • it will by default only show vessels which it knows anything useful about. click the "Show Empty" button to show all vessels
  • ship list can be filtered by vessel type
  • ship list can be filtered by SOI: in flight, relative to the active vessel; in the tracking station, relative to the selected object

 

How it acquires the data:

 

  • while in space, if the GUI is closed, it will collect the fuel data from the active vessel about every 10 seconds
  • otherwise, if the GUI is open, it will acquire data from all available vessels

 

Which data does it acquire:

 

  • the name of the ship
  • the number of crew aboard and maximum number of crew
  • and a currently hard-coded subset of the fuels (LiquidFuel, Oxidizer, MonoProp); the infrastructure is there to allow easily changing this, so it will work with any other resource, e.g. life support things etc.; if anybody is interested, this just requires some appropriate GUI work
  • no persistent storage; as soon as you return to the Main Menu, or exit the game, it's all discarded

 

Obligatory screenshots:

Javascript is disabled. View full album

Dependencies:

 

 

Release status: [thread=82996]release thread[/thread].

License: GPLv2; includes some code derived strongly from aviveys Switch Vessel Plugin, which is BSD-2 licensed.

Now, I'm posting this here because I also do have questions which maybe some of you might be able to answer:

 

  • is there a more elegant way to load the vessels (to be able to fetch the resources) without actually activating their PartModules? because I think this is what leads to some NREs
    solved
  • how would I go about re-using the vessel-type selection icons for my own settings/filter menu, and is this actually permitted (by Squad) ?
    using the recommendation by avivey yet; only downside so far is that it the icons are only loaded after switching (once) to the map view
  • something is weird with the GUI style in the Tracking Station, but I'm not too concerned about this right now
  • any ideas for the GUI? I know it would need a settings menu to select which resources it acquires, and also some filter options to improve the selection of which vessels it force-loads (ideally by individual vessel type, but see my question regarding the icons above); also some select to filter the output list; and it might be useful to sort the ship list by name (currently it is just the same order as your vessels appear elsewhere in the game, e.g. in the tracking station)

 

Cheers :)

 

Didgey @

http://forum.kerbalspaceprogram.com/threads/82996-0-23-5-WIP-Ship-List-v0-6?p=1214627&viewfull=1#post1214627

:

Could you make it so that you can select the SOI from a list instead of selecting it based on the ship you are controlling?

 

Edited by Kiwa
0.9 update for KSP 1.2
Link to comment
Share on other sites

With regards to the resource types, TacFuelBalancer by ThunderAerospace seems to inventory all resources, base and custom for a ship so it might be worth trying to chase down the source for that.

Link to comment
Share on other sites

Well - it already does search the list of registered resources (PartResourceLibrary.Instance.resourceDefinitions) and just filter the three I am interested in (by name). The only thing that is missing is a way to enable users to select the list of resources *they* are interested in, as opposed to *me*. Which means adding a GUI for this, with a list of resource check-boxes, or a config file. It might also lead to a requirement for persistent storage for this selection :/ Guess I will wait to see if there is actually any interest in this.

And I was actually more looking at the AlternateResourcePanel because it sports nice icons for the fuels, instead of my crude short two-letter labels, and also nice bar-graphs in addition to the raw numbers.

Link to comment
Share on other sites

Tips + shameless plug:

1. I think FlightGlobals.Vessels is the list of all ships in the game, including un-loaded ones. Take the ProtoVessel from each of those, and iterate over the ProtoParts - resource data is kept there, no need to actually load vessels. My similar plugin at http://forum.kerbalspaceprogram.com/threads/65769 does that for one ProtoVessel.

Unloaded vessels use no resources anyway.

2. Reusing squad icons is borderline impractical; There's no Texture object for them. I have a not-overly-maintainable solution at http://forum.kerbalspaceprogram.com/threads/78183 (Buttom of UI.cs) that you can reuse.

3. UI styles: The only thing I understand about Unity UI is that there's a global style variable, that you need to set before drawing your elements, and should restore when you're done.

Link to comment
Share on other sites

Well that's embarrassing. I totally assumed the ProtoVessel would only contain the "prototype", as in the VAB-design. If that lets me get rid of the loading... would be cool. Will definitely try it next.

Link to comment
Share on other sites

Github now has v0.3 commited.

Cleaned out all the vessel loading code, and actually got to test it. Didn't have any bad things in the debug console, so it looks stable enough for now.

Next planned feature will be the filtering of the list by vessel type, then the sorting, and possibly an option to ignore remove individual vessels from the list; but unlikely to happen this weekend.

Link to comment
Share on other sites

Filtering is basically functional and commited to github (v0.4). Only downside is it requires the ship list window to be opened once from the map view, otherwise the icons are not loaded/available :/

Code looks stable so far. Continuing with the plan, probably sorting will be next.

Link to comment
Share on other sites

In between, released fist public version (v0.5).

Instead of sorting, todays update includes a new feature: SOI-based filtering, available in-flight and in the tracking station. This actually reduces the vessel list so much that sorting probably will not be needed for now and I can focus on the resource selection, and maybe finally getting the GUI style problems sorted.

Or have any of you a strong preference to go for sorting first?

Link to comment
Share on other sites

  • 1 year later...
  • 6 months later...
  • 2 months later...
On ‎1‎/‎3‎/‎2017 at 10:21 AM, Stone Blue said:

Cant believe this mod isnt getting more love... Its awesome... :)

Agree!  Sometimes putting it on CKAN will gain it more exposure. Much of the time, someone will even volunteer to do the metadata for you.

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...