Jump to content

Detecting UIScrollList changes / when kerbals are added to vehicle crew list?


Recommended Posts

I'm trying to detect when kerbals are placed in a vehicle in the editors and the Launch Window (the window that pops up when you click on the Launch Pad or the Runway). I've been wracking my brain for a few days now, and I can't find anything. The UIScrollList that the available crew is kept in doesn't have any hooks for detecting when items are added/removed, and there aren't any other generic hooks available that I can find -- I tried GameEvents.onKerbalStatusChange(), but the kerbals' statuses don't change until you actually launch the vehicle. Does anyone have any insights?

Link to comment
Share on other sites

I'll look into it if I get some time today but it sounds like you're on the right track already if you have a hold of the right UIScrollList(s). Try adding delegates for drag and drop and value changed to it (AddDragDropDelegate, AddValueChangedDelegate, not the Set* ones). If that doesn't work, try adding an input delegate and checking the events yourself.

That's how I'd start. If neither of those work, we'll dig in further

Link to comment
Share on other sites

Hmmm. I don't remember if I tried the SetXDelegate or AddXDelegate methods. Whichever one I chose didn't do anything. I'll definitely try them again. I'm not actually familiar with how the Input Delegate works, to be honest, but I'll experiment.

Link to comment
Share on other sites

Alright, AddValueChangedDelegate gives me a hook into when kerbals are added back into the UIScrollList, but not when they're taken out. That's okay for my application, but I thought I'd warn future readers. Unfortunately, I've just discovered that in the Launch Window and the Editor, you can drag and drop kerbals to temporarily swap them or put them into ships. You can also drag them back into the list, but this doesn't trigger the ValueChangedDelegate or any of the other publicly available hooks on the UIScrollList. The InputDelegate hook on the list items themselves will tell you when the user is dragging a kerbal, but the other delegates don't do anything. Damnit. I suppose that's a start, though...

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